package com.knowledge.graph.controller;

import com.knowledge.graph.service.GraphService;
import com.knowledge.graph.model.vo.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jiwenlong
 * @version 1.0
 * @description: 处理知识图谱的相关请求
 * @date 2023/11/10 21:47
 */
@RestController
public class GraphController {

    @Autowired
    private GraphService graphService;

    @GetMapping("/graphType")
    public ResponseVO getGraphType() {
        return graphService.getGraphType();
    }

    @GetMapping("/graph")
    public ResponseVO getGraphByCourse(@RequestParam("courseID") Integer courseID) {
        return graphService.getGraphByCourse(courseID);
    }

    @GetMapping("/graphByLayers")
    public ResponseVO getGraphByLayers(@RequestParam("nodeName") String nodeName, @RequestParam("nodeType") String nodeType, @RequestParam("layers") Integer layers) {
        return graphService.getGraphByLayers(nodeName, nodeType, layers);
    }


    @PostMapping("/graphType")
    public ResponseVO addGraphType(@RequestParam("courseNodeType") String courseNodeType, @RequestParam("courseID") Integer courseID) {
        return graphService.addGraphType(courseNodeType, courseID);
    }

    @GetMapping("/nodeID")
    public ResponseVO getVideoID(@RequestParam("nodeID")Integer nodeID) {
        return graphService.getVideoByNodeID(nodeID);
    }

}
